package org.jsets.fastboot.security.authc;

import org.springframework.security.crypto.password.PasswordEncoder;
import cn.hutool.crypto.digest.DigestUtil;

public class Sha256PasswordEncoderImpl implements PasswordEncoder {

	@Override
	public String encode(CharSequence charSequence) {
		return DigestUtil.sha256Hex(charSequence.toString());
	}

	@Override
	public boolean matches(CharSequence charSequence, String encodedPassword) {
		System.out.println(encodedPassword);
		System.out.println(charSequence);
		System.out.println(DigestUtil.sha256Hex(charSequence.toString()));
		return encodedPassword.equals(DigestUtil.sha256Hex(charSequence.toString()));
	}
}
